package com.sq.service.impl;

import com.sq.service.SystemService;
import org.springframework.stereotype.Service;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.software.os.OperatingSystem;

import java.util.HashMap;
import java.util.Map;

@Service
public class SystemServiceImpl implements SystemService {
    @Override
    public String getSystemInfo() {
        Map<String, Object> resultMap = new HashMap<>();
        String result="";

        SystemInfo si = new SystemInfo();
        OperatingSystem operatingSystem= si.getOperatingSystem();

        //获取操作系统名称
        String manufacturer=  operatingSystem.getManufacturer();
        OperatingSystem.OSVersionInfo osVersionInfo=operatingSystem.getVersionInfo();
        osVersionInfo.getVersion();
        osVersionInfo.getBuildNumber();
        osVersionInfo.getCodeName();
        //网速，cpu,内存，硬盘空间,服务在线状态
        operatingSystem.getFileSystem();
        return result;
    }

    public static void main(String[] args) {
        Map<String, Object> resultMap = new HashMap<>();

        SystemInfo si = new SystemInfo();
        OperatingSystem operatingSystem= si.getOperatingSystem();

        //获取操作系统名称
        String family= operatingSystem.getFamily();
        resultMap.put("family", family);
        String manufacturer=  operatingSystem.getManufacturer();
        resultMap.put("manufacturer", manufacturer);
        OperatingSystem.OSVersionInfo osVersionInfo=operatingSystem.getVersionInfo();
        String version= osVersionInfo.getVersion();
        resultMap.put("version", version);
        String buildNumber=osVersionInfo.getBuildNumber();
        resultMap.put("buildNumber", buildNumber);
        String codName=osVersionInfo.getCodeName();
        resultMap.put("codName", codName);
        //网速，cpu,内存，硬盘空间,服务在线状态
//        String fileSystem=operatingSystem.getFileSystem().get;
//        resultMap.put("fileSystem", fileSystem);
        HardwareAbstractionLayer hal=  si.getHardware();
        CentralProcessor centralProcessor= hal.getProcessor();
        resultMap.put("111",centralProcessor.getContextSwitches());

        resultMap.put("逻辑处理器计数",centralProcessor.getLogicalProcessorCount());
        resultMap.put("物理处理器数",centralProcessor.getPhysicalProcessorCount());

//        resultMap.put("333",centralProcessor.getLogicalProcessors());
//        resultMap.put("444",centralProcessor.getCurrentFreq());
//        resultMap.put("555",centralProcessor.getMaxFreq());



        //函数，


        System.out.println(resultMap);

    }
}
